/**
 * 
 * 遍历，组装
 * @param {string} s
 * @return {string[]}
 */
var restoreIpAddresses = function (s) {
    if (s.length < 4) {
        return []
    }
    let rslt = []
    let tempArr = new Array(4).fill()
    function walk(index, count) {
        if (count === 4) {
            if (index === s.length) {
                rslt.push(tempArr.join('.'))
            }
            return
        }
        for (let i = 1; i <= 3 && index + i <= s.length; i++) {
            let t = s.slice(index, index + i)
            if (i > 1 && (t[0] === '0' || Number(t) > 255)) {
                continue
            }
            tempArr[count] = t
            walk(index + i, count + 1)
        }
    }
    walk(0, 0)
    return rslt
};

console.log(restoreIpAddresses("101012"))